package com.hngy.xpq.shoppingcartmodule.ui.dashboard;

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.hngy.xpq.shoppingcartmodule.R;
import com.hngy.xpq.shoppingcartmodule.bean.Cart;
import com.hngy.xpq.shoppingcartmodule.database.SqlCart;
import com.hngy.xpq.shoppingcartmodule.database.SqlShop;
import com.hngy.xpq.shoppingcartmodule.tool.alg;

import java.util.ArrayList;
import java.util.List;

public class DashboardViewModel extends ViewModel {

    private MutableLiveData<List<Cart>> mCart;
    private SqlCart sqlChat;

    public LiveData<List<Cart>> getListChat(View root) {
        mCart = new MutableLiveData<>();   // 监察者模式
        sqlChat = new SqlCart(root.getContext());
        List<Cart> list = sqlChat.select(root);
        mCart.setValue(list);
        return mCart;
    }

    public void gengxing(View root) {
        List<Cart> list = sqlChat.select(root);
        mCart.postValue(list);
    }



}